{extend name='common:base'}
{block name="content"}
<form class="form-horizontal" id="form" method="post" action="">
    <div class="form-group">
        <label for="inputEmail3" class="col-sm-2 control-label">用户名</label>
        <div class="col-sm-10">
            <input type="email" name="mname" value="{$oldData['mname']}" class="form-control" data-rule-required="true" data-msg-required="必须输入" id="inputEmail3" placeholder="请输入邮箱注册" data-rule-rangelength="[6,30]" data-msg-rangelength="用户名必须大于6位">
        </div>
    </div>

    <div class="form-group">
        <label for="confPassword" class="col-sm-2 control-label">状态</label>
        <div class="col-sm-10">
            <label class="radio-inline">
                <input type="radio" name="status"  value="1" {if condition="$oldData['status'] eq 1"}checked {/if}> 启用
            </label>
            <label class="radio-inline">
                <input type="radio" name="status"  value="0" {if condition="$oldData['status'] eq 0"}checked {/if}> 禁用
            </label>
        </div>
    </div>
    <div class="form-group">
        <label for="confPassword" class="col-sm-2 control-label">超级管理员</label>
        <div class="col-sm-10">
            <label class="radio-inline">
                <input type="radio" name="is_super"  value="1" {if condition="$oldData['is_super'] eq '1'"} checked {/if}> 是
            </label>
            <label class="radio-inline">
                <input type="radio" name="is_super"  value="0" {if condition="$oldData['is_super'] eq '0'"} checked {/if}> 否
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="layui-form-label"></label>
        <a class="layui-btn" id="image" style="float: left;"><i class="layui-icon">&#xe67c;</i>上传图片</a>
        <div class="layui-input-block" style="margin-left: 220px;">
            <input type="text" name="image" value="{$oldData['image']}" class="layui-input" style="position: absolute;left: 0;top: 0;" readonly>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <img style="margin-left: 130px;" id="img" src="{$oldData['image']}">
        </div>
    </div>
    <input type="hidden" name="__token__" value="{$Request.token}">
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" class="btn btn-default">提交</button>
        <button type="reset" class="btn btn-default">取消</button>
    </div>
    </div>
</form>
{/block}

{block name="extend_js"}
<script src="/bower/jquery-validation/dist/jquery.validate.js"></script>
<script src="/bower/jquery-validation/src/localization/messages_zh.js"></script>
<script>
    $().ready(function(){
        $("#form").validate();
    });
    layui.use('upload',function(){
        var $=layui.$
            ,upload=layui.upload
            ,layer=layui.layer;
        var uploadInst=upload.render({
            elem:'#image'
            ,url:'{:url("api/Open/imgUpload")}' //文件上传接口
            ,ext:'jpg|png|gif'
            ,area:'200px'
            //载入前配置
            ,before:function(){
                loading=layer.load(2,{shade:[0.2,'#000']});
            }
            ,done:function(res){
                layer.close(loading);
                layer.msg(res.msg);
                console.log(res);
                //上传完成显示地址到input
                $('input[name=image]').val(res.path);
                $('#img').attr('src',res.path);
            }
            ,error:function(){
//                请求异常回调
            }
        })
    });
</script>
{/block}